<!DOCTYPE html>
<!--
  ~ Copyright (c) 2018.
  ~ This file was written by fancyears·milos·malvis @connor. Any question/bug you can't post to 1243093366@qq.com.
  ~ ALL RIGHTS RESERVED.
  -->
<!--一阶段可单独在当前项目添加特性，二阶段已从配置字典中获取，从而移除单独修改特性功能，因此该页面将废除-->
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<link th:href="@{/css/labelColor.css}" rel="stylesheet">
<head>
    <meta charset="UTF-8">
    <title>修改特性(已废除)</title>
</head>
<body>
<form id="featureForm" role="form" method="post" th:action="${action}">
    <input class="form-control" id="puid" name="puid" type="hidden" th:value="${entity.puid}"/>
    <input class="form-control" id="pCfg0MainItemPuid" name="pCfg0MainItemPuid" type="hidden"
           th:value="${entity.pCfg0MainItemPuid}"

    />
    <input class="form-control" id="pCfg0FamilyPuid" name="pCfg0FamilyPuid" type="hidden"
           th:value="${entity.pCfg0FamilyPuid}"
    />
    <div class="form-group">
        <label for="pCfg0FamilyName">特性名称<span>*</span></label>
        <input class="form-control" id="pCfg0FamilyName" name="pCfg0FamilyName" type="text"
               th:value="${entity.pCfg0FamilyName}" disabled="disabled"
               placeholder="请输入特性名称"
        />
    </div>
    <div class="form-group">
        <label for="pCfg0FamilyDesc">特性描述<span>*</span></label>
        <input class="form-control" id="pCfg0FamilyDesc" name="pCfg0FamilyDesc" type="text"
               th:value="${entity.pCfg0FamilyDesc}"
               placeholder="请输入特性描述"/>
    </div>
    <div class="form-group">
        <label for="pH9featureenname">特性英文名称</label>
        <input class="form-control" id="pH9featureenname" name="pH9featureenname" type="text"
               th:value="${entity.pH9featureenname}"
               placeholder="请输入特性英文名称"/>
    </div>
    </div>
    <div class="form-group">
        <label for="pCfg0ObjectId">特性值/配置代码<span>*</span></label>
        <input class="form-control" id="pCfg0ObjectId" name="pCfg0ObjectId" type="text"
               th:value="${entity.pCfg0ObjectId}" disabled="disabled"
               placeholder="请输入特性值/配置代码"
        />
    </div>
    <div class="form-group">
        <label for="pCfg0Desc">特性值/配置(描述)<span>*</span></label>
        <input class="form-control" id="pCfg0Desc" name="pCfg0Desc" type="text" th:value="${entity.pCfg0Desc}"
               placeholder="请输入特性值/配置(描述)"
        />
    </div>
    <!--<div class="form-group">-->
    <!--<label for="length">字符长度</label>-->
    <!--<input class="form-control" id="length" name="length" type="text" value="10" th:value="${entity.length}"-->
    <!--placeholder="请输入字符长度"/>-->
    <!--</div>-->
</form>
<script th:inline="javascript">
    <![CDATA[
    $(function () {
        $('#featureForm').bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                pCfg0FamilyName: {
                    message: '特性名称验证失败',
                    validators: {
                        notEmpty: {
                            message: '特性名称不能为空'
                        },
                        //正则校验
                        regexp: {
                            regexp: /^[a-zA-Z][a-zA-Z0-9]*$/, /* ^ 指的是匹配字符串开始的位置 + 匹配一个或者多个*/
                            message: '特性只能以英文开头，加英文和数字，不允许有英文和数字以外的字符'
                        },
                        stringLength: {
                            max: 10,
                            message: '特性最长长度为10'
                        },
                    }
                },
                pCfg0FamilyDesc: {
                    message: '特性描述验证失败',
                    validators: {
                        notEmpty: {
                            message: '特性描述不能为空'
                        }
                    }
                },
                pCfg0ObjectId: {
                    message: '特性值/配置代码验证失败',
                    validators: {
                        notEmpty: {
                            message: '特性值/配置代码不能为空'
                        },
                        //正则校验
                        regexp: {
                            regexp: /[a-zA-Z0-9]+$/, /* ^ 指的是匹配字符串开始的位置 + 匹配一个或者多个*/
                            message: '特性值只能以数字/英文开头，加英文和数字，不允许有英文和数字以外的字符'
                        },
                        stringLength: {
                            max: 10,
                            message: '特性值最长长度为10'
                        },
                    }
                },
                pCfg0Desc: {
                    message: '特性值/配置(描述)验证失败',
                    validators: {
                        notEmpty: {
                            message: '特性值/配置(描述)不能为空'
                        }
                    }
                },
                length: {
                    message: '字符长度验证失败',
                    validators: {
                        digits: {
                            message: '长度只能是整数'
                        }
                    }
                },
            }
        });
        // 绑定dialog的确定按钮的监听事件
        $("#btnOk", window.top.document).click(function () {
            var bootstrapValidator = $("#featureForm", window.top.document).data('bootstrapValidator');
            bootstrapValidator.validate();
            if (bootstrapValidator.isValid()) {
                var url = $("#featureForm", window.top.document).attr('action');
                <!--其实不要puid，puid会在服务器上生成-->
                var myData = JSON.stringify({
                    "puid": $("#puid").val(),
                    "pCfg0FamilyPuid": $("#pCfg0FamilyPuid").val(),
                    "pCfg0FamilyName": $("#pCfg0FamilyName").val(),
                    "pCfg0FamilyDesc": $("#pCfg0FamilyDesc").val(),
                    "pCfg0ObjectId": $("#pCfg0ObjectId").val(),
                    "pCfg0Desc": $("#pCfg0Desc").val(),
                    "pH9featureenname": $("#pH9featureenname").val(),
                    "length": $("#length").val(),
                    "pCfg0MainItemPuid": $("#pCfg0MainItemPuid").val()
                });
                $.ajax({
                    contentType:
                        "application/json",
                    type:
                        'POST',
                    url: url,
                    data: myData,
                    success:
                        function (result) {
                            // $('.modal-dialog', window.top.document).parent('div').remove()
                            // $('body', window.top.document).find('.modal-backdrop').remove();
                            // jquery 调用刷新当前操作的table页面的refresh方法
                            // $(window.parent.document).contents().find(".tab-pane.fade.active.in iframe")[0].contentWindow.doQuery();
                            activeTabBodyRefresh();
                            if (result.status) {
                                layer.msg(result.msg, {icon: 1, time: 2000})
                            }
                            else {
                                window.Ewin.alert({message: result.msg});
                            }
                        },
                    error: function (status) {
                        window.Ewin.alert({message: status.status + ':修改数据失败!'});
                    }
                });
            }
        });
    })
    ]]>
</script>
<script th:src="@{/layer/layer.js}"></script>
</body>
</html>